Skip to content

fix(sandbox): switch alwaysStrict default to false - #3019

Closed
Josh Goldberg ✨ (JoshuaKGoldberg) wants to merge 1 commit into
microsoft:v2from
JoshuaKGoldberg:sandbox-alwaysStrict-default-false
Closed

fix(sandbox): switch alwaysStrict default to false#3019
Josh Goldberg ✨ (JoshuaKGoldberg) wants to merge 1 commit into
microsoft:v2from
JoshuaKGoldberg:sandbox-alwaysStrict-default-false

Conversation

@JoshuaKGoldberg

Copy link
Copy Markdown
Contributor

Per my interpretation of a brief discussion on alwaysStrict in Discord, changes the default value for that setting to off.

Note that this doesn't imply anything about TypeScript's recommendations around strict mode. It just changes the playground to not emit a "use strict"; on top of emitted JS. That string has been a thorn in my side trying to teach TypeScript in workshops for years.

@jakebailey

Copy link
Copy Markdown
Member

I am still not entirely convinced that this is a good idea, but, in what conditions do we currently actually emit it? The default settings on the playground don't show "use strict"; in the JS output.

@JoshuaKGoldberg

Copy link
Copy Markdown
Contributor Author

If the current file is a script (rather than a module). https://www.typescriptlang.org/play?#code/Q:

Screenshot of the TypeScript playground with no input code. The output is "use strict";

@jakebailey

Copy link
Copy Markdown
Member

Ah, I had some stuff sitting in my browser.

@jakebailey Jake Bailey (jakebailey) added the deploy-preview Enables automatic deployments to preview environments on a PR label Feb 1, 2024
@jakebailey

Copy link
Copy Markdown
Member

Per microsoft/TypeScript#62213, we're going in the opposite direction on this such that all code will be forcibly strict (and get this prologue if not ESM).

I think better would be to modernize the playground's options to not target CJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-preview Enables automatic deployments to preview environments on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants